package MaintMenu.VenPricingUpdMasterFiles.Mast1ToMastMenu;// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.



/////***** Make sure you are certain of replacing MAST with MAST1 fiels    ********\\\\\\
import javax.swing.*;
import java.sql.*;

public class Trn6CategoryUpdateMasterfiles
{

    public Trn6CategoryUpdateMasterfiles(String cat, String cat1){

        long tStart = System.currentTimeMillis();
        long tStop =0;


        try
        {
            tStart = System.currentTimeMillis();
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String dataSourceName = "dbLI";
            String dbURL = (new StringBuilder()).append("jdbc:odbc:").append(dataSourceName).toString();
            Connection con = DriverManager.getConnection(dbURL, "", "");
            Statement st = con.createStatement();
            Statement st1 = con.createStatement();
            Statement st2 = con.createStatement();
            Statement st3 = con.createStatement();
            Statement st4 = con.createStatement();
            Statement st5 = con.createStatement();
            Statement st6 = con.createStatement();


            System.out.println("Processing "+cat+ " please wait....\n");

            st.execute("delete * from " +cat+ ";");
            st.execute("select * from " +cat1+ ";");
            ResultSet rs1 = st.getResultSet();
            if(rs1 != null)
            {
                String part = "null";
                while(rs1.next())
                {
                    part = rs1.getString("item_no");
                    try
                    {
                        st1.execute("insert into "+ cat +" select * from " +cat1 + " where item_no= '" + part + "';");
                    }
                    catch(SQLException er) { }
                }
                System.out.printf("%s to %s done\n", cat, cat1);

            }
            tStop = System.currentTimeMillis();
            System.out.println("Total time for "+ cat+ " :"+ (tStop-tStart)/1000+ " seconds");

        st.close();
        st1.close();
        st2.close();
        st3.close();
        st4.close();
        st5.close();
        st6.close();
        con.close();

    }catch(Exception e)
        {
            JOptionPane.showMessageDialog(null, e);
            e.printStackTrace();
        }
    }
}
